/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dk.eleit;

/**
 *
 * @author menderleit
 */
class Vector3 {
    private double x, y, z;

    public Vector3() {
        x = 0.0f;
        y = 0.0f;
        z = 0.0f;
    }
    
    public Vector3(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public void setVector(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public double getLength() {
        return Math.sqrt((x*x)+(y*y)+(z*z));
    }
    
    public Vector3 Normalize() {
        double l = this.getLength();
        Vector3 v = new Vector3(x/l, y/l, z/l);
        return v;
    }

    public Vector3 rotate(double x, double y, double z) {
        Vector3 v = new Vector3();
        // X-Axis
        v.setY(this.y * Math.cos(Math.toRadians(x)) - this.z * Math.sin(Math.toRadians(x)));
        v.setZ(this.y * Math.sin(Math.toRadians(x)) + this.z * Math.cos(Math.toRadians(x)));
        // Y-Axis
        v.setX(this.x * Math.cos(Math.toRadians(y)) + v.getZ() * Math.sin(Math.toRadians(y)));
        v.setZ(this.x * -Math.sin(Math.toRadians(y)) + v.getZ() * Math.cos(Math.toRadians(y)));
        return v;
    }
    
    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getZ() {
        return z;
    }

    public void setZ(double z) {
        this.z = z;
    }
}
